/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package parismetro;

import javafx.scene.CustomNode;
import javafx.scene.Node;
import javafx.scene.Group;
import javafx.scene.shape.Rectangle;
import javafx.scene.paint.Color;
import javafx.scene.paint.LinearGradient;
import javafx.scene.paint.Stop;
import javafx.scene.paint.CycleMethod;
import javafx.scene.text.Text;
import javafx.scene.text.Font;
import javafx.animation.Timeline;
import javafx.animation.Interpolator;
import javafx.scene.input.MouseEvent;
import javafx.animation.transition.SequentialTransition;

/**
 * @author Hadrien
 */
public class DialogMap extends CustomNode {

    init {
        this.visible = false;
    }

    var largeur= 1000;
    var hauteur= 750;
    public var choixStation : ChoixStation;

    var rad: Integer = 50;
    var l: Integer = rad;
    var h: Integer = rad;
    public var afficher: Boolean = false on replace {
                if (this.visible == false) {
                    choixStation.carte.isDialogDiplayed = true;
                    this.visible = afficher;
                    SequentialTransition {content: [
                            Timeline {
                                repeatCount: 1
                                keyFrames: [
                                    at (200ms) {l => largeur tween Interpolator.EASEOUT}]
                            },
                            Timeline {
                                repeatCount: 1
                                keyFrames: [
                                    at (500ms) {h => hauteur tween Interpolator.EASEOUT}]
                            },

                        ]}.play();

                } else {
                    this.visible = afficher;
                    l = rad;
                    h = rad;
                    choixStation.carte.isDialogDiplayed = false;
                }
            };
    

    var g: Group;
    var fond: Rectangle = Rectangle {
                width: 1024, height: 768
                fill: LinearGradient {
                    cycleMethod: CycleMethod.REPEAT
                    startX: 0.0
                    startY: 0.0
                    endX: 0.002
                    endY: 0.001
                    stops: [
                        Stop {
                            color: Color.WHITE
                            offset: 0.0
                        },
                        Stop {
                            color: Color.BLACK
                            offset: 1.0
                        },
                    ]
                }
                opacity: 0.6
            }

     var fondMap= Rectangle {
                width: 970;
                height: 740;
                layoutX: bind ((1024 - l) / 2)
                layoutY: bind ((768 - h) / 2)
                fill: Color.WHITE;
                arcWidth: rad;
                arcHeight: rad;
     }

    var dialog: Group = Group {
                layoutX: bind ((1024 - l) / 2)
                layoutY: bind ((768 - h) / 2)
                content: [fondMap, choixStation.carte]
   }

    override function create(): Node {
        g = Group {
                    content: [fond, dialog]
                    //onMousePressed: function(e: MouseEvent): Void {
                    //    afficher = false;
                    //}
                }
        return g;
    }

}
